package com.wanczy.dao.proxy;

import java.sql.Connection;
import java.util.List;

import org.apache.commons.dbutils.DbUtils;

import com.wanczy.dao.UserRoleTableDAO;
import com.wanczy.dao.impl.UserRoleTableDAOImpl;
import com.wanczy.pojo.UserRoleTable;
import com.wanczy.util.GetDBConnection;

public class UserRoleTableDAOProxy implements UserRoleTableDAO {
	public Connection conn;
	public UserRoleTableDAOImpl impl = null;
	public UserRoleTableDAOProxy() {
		try {
			this.conn = GetDBConnection.getConnection();// 取得数据库连接
			this.impl = new UserRoleTableDAOImpl(this.conn);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	@Override
	public List<UserRoleTable> find(int userId) {
		List<UserRoleTable> list = this.impl.find(userId);
		DbUtils.closeQuietly(conn);
		return list;
	}

	@Override
	public boolean doIns(UserRoleTable userRole) {
		boolean flag = this.impl.doIns(userRole);
		DbUtils.commitAndCloseQuietly(conn);
		return flag;
	}

	@Override
	public boolean doDel(int userId) {
		boolean flag = this.impl.doDel(userId);
		DbUtils.commitAndCloseQuietly(conn);
		return flag;
	}
	@Override
	public List<UserRoleTable> findAllRole( ) {
		List<UserRoleTable> list = this.impl.findAllRole();
		DbUtils.closeQuietly(conn);
		return list;
	}
	@Override
	public List<UserRoleTable> findAllUSer() {
		List<UserRoleTable> list = this.impl.findAllUSer();
		DbUtils.closeQuietly(conn);
		return list;
	}
}
